package com.quanyan.club.task.tracker;

import com.github.ltsopensource.core.domain.Action;
import com.github.ltsopensource.tasktracker.Result;
import com.github.ltsopensource.tasktracker.runner.JobContext;
import com.github.ltsopensource.tasktracker.runner.JobRunner;
import com.quanyan.club.service.ClubService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2016/7/27.
 *
 * 俱乐部积分任务逻辑处理
 */
@Component
public class ClubIntegralStatsJob implements JobRunner{
    private static final Logger logger = LoggerFactory.getLogger(ClubIntegralStatsJob.class);
    @Autowired
    private ClubService clubService;

    @Override
    public Result run(JobContext jobContext) throws Throwable {
        try {
            //更新各俱乐部积分
            clubService.updateClubIntegral();
        }catch (Exception e){
            logger.info("俱乐部积分任务执行失败！", e);
            return new Result(Action.EXECUTE_LATER, "俱乐部积分任务执行失败"+e.getMessage());
        }

        return new Result(Action.EXECUTE_SUCCESS,"俱乐部积分任务执行成功");
    }
}
